package com.gzedu.ecloud.common.http.result;

public class Result {
  private int ret;
  private String msg;
  private Object result;
  private final static int SUCCESS = 0;
  private final static int FAIL = 1;

  public int getRet() {
    return ret;
  }

  public void setRet(int ret) {
    this.ret = ret;
  }

  public String getMsg() {
    return msg;
  }

  public void setMsg(String msg) {
    this.msg = msg;
  }

  public Object getResult() {
    return result;
  }

  public void setResult(Object result) {
    this.result = result;
  }

  public static Result suc(Object result) {
    Result res = new Result();
    res.setRet(SUCCESS);
    res.setMsg("");
    if (result == null) {
      result = "";
    }
    res.setResult(result);
    return res;
  }

  public static Result suc() {
    return suc(null);
  }

  public static Result fail(int ret, String msg) {
    Result res = new Result();
    res.setRet(ret);
    res.setMsg(msg);
    res.setResult("");
    return res;
  }

  public static Result fail(String msg) {
    Result res = new Result();
    res.setRet(FAIL);
    res.setMsg(msg);
    res.setResult("");
    return res;
  }
}
